package serviceset2

import grails.testing.gorm.DomainUnitTest
import spock.lang.Specification

class GoodsSpec extends Specification implements DomainUnitTest<Goods> {

    def setup() {
    }

    def cleanup() {
    }

    void "test a valid properties"() {
        given:
        def params = [name: "motor g", brand: "motor", price: 10.2]

        when:
        def goodsInstance = new Goods(params)
        goodsInstance.save()

        then:
        !goodsInstance.hasErrors()
    }

    void "test an invalid properties"() {
        given:
        def params = [name: "motor g", price: -1]

        when:
        def goodsInstance = new Goods(params)
        goodsInstance.save()

        then:
        goodsInstance.hasErrors()
        goodsInstance.errors.allErrors.size() == 2
    }
}
